package com.ruoyi.web.controller.douyin;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaIgnore;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.DyAnchorPhoto;
import com.ruoyi.system.domain.DyClientAnchor;
import com.ruoyi.system.domain.DyGoods;
import com.ruoyi.system.domain.bo.*;
import com.ruoyi.system.domain.vo.*;
import com.ruoyi.system.service.IDyAnchorService;
import com.ruoyi.system.service.IDyClientAnchorService;
import com.ruoyi.system.service.IDyClientService;
import com.ruoyi.system.vo.DyClientLoginVo;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * 小程序客户端
 *
 * @author ruoyi
 * @date 2024-06-20
 */

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/client")
public class DyClientController extends BaseController {

    private final IDyClientAnchorService iDyClientAnchorService;

    private final IDyClientService iDyClientService;

    /**
     * 查询我的主播列表
     */
    @GetMapping("/getClientAnchorList")
    @SaIgnore
    public TableDataInfo<DyClientAnchorVo> getClientAnchorList(DyClientAnchorBo bo, PageQuery pageQuery) {
        return iDyClientAnchorService.getClientAnchorList(bo, pageQuery);
    }

    /**
     * 查询我的主播相册
     */
    @GetMapping("/getClientAnchorAlbumList")
    @SaIgnore
    public TableDataInfo<DyAnchorPhotoVo> getClientAnchorAlbumList(DyClientAnchorBo bo, PageQuery pageQuery) {
        return iDyClientAnchorService.getClientAnchorAlbumList(bo, pageQuery);
    }

    /**
     * 获取主播相册详细信息
     *
     * @param bo 主键
     */
    @GetMapping("/getClientAnchorInfo")
    @SaIgnore
    public TableDataInfo<DyAnchorPhotoDetailVo> getClientAnchorInfo(DyClientAnchorBo bo, PageQuery pageQuery) {
        return iDyClientAnchorService.getClientAnchorInfo(bo, pageQuery);
    }


    /**
     * 客户端登录
     *
     * @param bo 主键
     */
    @PostMapping("/login")
    @SaIgnore
    public R<DyClientLoginVo> login(@RequestBody DyClientBo bo) {
        return iDyClientService.login(bo);
    }

    /**
     * 客户端注册
     *
     * @param bo 主键
     */
    @PostMapping("/register")
    @SaIgnore
    public R<DyClientLoginVo> register(@RequestBody DyClientBo bo) {
        return iDyClientService.register(bo);
    }

    /**
     * 查询推荐列表
     */
    @GetMapping("/getRecommendPage")
    public TableDataInfo<DyGoodsVo> getRecommendPage(DyGoodsBo bo, PageQuery pageQuery) {
        return iDyClientAnchorService.getRecommendPage(bo, pageQuery);
    }

    /**
     * 查询新品列表
     */
    @GetMapping("/getNewPhotosPage")
    public TableDataInfo<DyAnchorPhotoVo> getNewPhotosPage(DyAnchorPhotoBo bo, PageQuery pageQuery) {
        return iDyClientAnchorService.getNewPhotosPage(bo, pageQuery);
    }

    /**
     * 查询推荐详情
     */
    @GetMapping("/getRecommendDetailPage")
    public TableDataInfo<DyAnchorPhotoVo> getRecommendDetailPage(DyGoodsBo bo, PageQuery pageQuery) {
        return iDyClientAnchorService.getRecommendDetailPage(bo, pageQuery);
    }

    /**
     * 下单主播
     *
     * @param bo 主键
     */
    @PostMapping("/buyClientAnchor")
    @SaIgnore
    public R<String> buyClientAnchor(@RequestBody DyClientAnchorBo bo) {
        return iDyClientService.buyClientAnchor(bo);
    }

    /**
     * 下单主播相册
     *
     * @param bo 主键
     */
    @PostMapping("/buyClientAnchorPhoto")
    @SaIgnore
    public R<String> buyClientAnchorPhoto(@RequestBody DyAnchorPhotoBo bo) {
        String result = iDyClientService.buyClientAnchorPhoto(bo);
        return R.ok(result);
    }

}
